package com.szp.springbootvue.utils;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class SecurityResult {
    private SecurityResult(){}

    public static void creatReturnMsg(ServletResponse response, String returnMsg) throws IOException {
        HttpServletResponse response1 = (HttpServletResponse)response;
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = response1.getWriter();
        out.write(new ObjectMapper().writeValueAsString(returnMsg));
        out.flush();
        out.close();
    }
}
